package com.tmz.cloudmall.cloudmallcommon.config.webflux;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;

/**
 * @ClassName GatewaySecurityConfig
 * @Description gateway专用安全配置类
 * @Author tmz
 * @Date 2025/9/1
 */
@Configuration
@EnableWebFluxSecurity
@Slf4j
public class GatewaySecurityConfig {
    @Bean
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
        // 输出配置加载日志
        log.info("===== 开始加载 Security 配置 =====");
        return http
                .csrf().disable()
                .authorizeExchange()
                .anyExchange().permitAll()
                .and()
                .build();
    }
}
